package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"project/controller"
	"project/controller/basic"
	"project/controller/interaction"
	"project/controller/socializing"
	"project/mySql"
)

func main() {
	addr := controller.GetIPv4Address() //获取本地IPv4地址
	fmt.Println(addr)                   //打印出项目服务地址，需要在软件中更改
	// 数据库的初始化与连接
	mySql.SqlInit()
	//gin设置，获取gin对象
	r := gin.Default()
	r.Static("/static", "./public")
	apiRouter := r.Group("/douyin")

	//gin连接接口
	apiRouter.POST("/user/login/", basic.Login)
	apiRouter.GET("/user/", basic.ReturnUserInfo)
	apiRouter.GET("/feed/", basic.Feed)
	apiRouter.POST("/user/register/", basic.Register)
	apiRouter.POST("/comment/action/", interaction.CommentAction)
	apiRouter.GET("comment/list/", interaction.CommentList)
	apiRouter.POST("/relation/action/", socializing.FollowAction)
	apiRouter.GET("/relation/follow/list/", socializing.FollowList)
	apiRouter.GET("/relation/follower/list/", socializing.FollowerList)
	apiRouter.GET("/relation/friend/list/", socializing.FriendList)
	apiRouter.POST("/publish/action/", basic.Publish)
	apiRouter.GET("/publish/list/", basic.PublishList)
	apiRouter.POST("/favorite/action/", interaction.FavoriteAction)
	apiRouter.GET("/favorite/list/", interaction.Favoritelist)
	apiRouter.POST("/message/action/", socializing.ChatAction)
	apiRouter.GET("/message/chat/", socializing.ChatHistory)

	basic.PubR(r)
	//连接接口
	err := r.Run(addr)
	if err == nil {
		fmt.Println(err)
	}
}
